
{literal}
<script type="text/javascript">

var cbCount;

function selectAll(state){
	for(var i=0;i<document.userStats.elements.length;i++){
		if (document.userStats.elements[i].getAttribute('type')=='checkbox')
	 	document.userStats.elements[i].checked = state;
	}
}


function checkEmpty(){
	//var formel = document.userStats.elements;
	var isChecked = false;
	var i
	var s=0;
	for(var i=0;i<document.userStats.elements.length;i++){
		if (document.userStats.elements[i].getAttribute('type')=='checkbox' && document.userStats.elements[i].checked){
       isChecked = true;
       s++;
       }
	}
    return s;
}


function formSubmit(){
     if(!checkEmpty()) {
     	alert ("Select at least one entry!");
     	return;
     }
     //alert(document.getElementById("action").value);
     if (document.getElementById("mailshotMode").value == "EmailNegativePerf"){
     	 document.getElementById("action").value = 1;
     }
     //alert(document.getElementById("action").value);
     if (confirm("Message will be sent to "+checkEmpty()+" user(s)!"))
     document.userStats.submit();
}


function setNegativeCB() {

 	var cnter=1;
 	while(document.getElementById("trial"+cnter)) {
 		if(document.getElementById("trial"+cnter).value=="" && document.getElementById("subscr"+cnter).value==0 && document.getElementById("pips"+cnter).value<=0)
 			document.getElementById(cnter).checked=true;
 		cnter++;
 	}
}

function showActCode(iid) {
	var inputname = "code"+iid;
    if(document.getElementById("code"+iid).style.display=="none"){
 		document.getElementById("code"+iid).style.display="block";
 		//document.userStats.inputname.select();
 		//document.userStats.inputname.focus();
 	} else{
 		document.getElementById("code"+iid).style.display="none";
 	}
}

function deleteUser(uid,uname,umail) {

 	if (confirm("Do you really want to delate user "+uname+"("+umail+")?") && confirm("Do you still want to delate user "+uname+"("+umail+") ?")){
 			document.location="admin.php?p=userstats&uid="+uid+"&action=delete";
 	}
}


</script>
{/literal}

{$userAdmin->loadForecasts()}
<h3>User stats </h3>

{include file="admin/admin_menu.tpl"}


{section name=pages loop=$userAdmin->pagingData}
| <a href="admin.php?p=userstats&start={$userAdmin->pagingData[pages].param.start}" {if $smarty.get.start==$userAdmin->pagingData[pages].param.start}style="text-decoration: none"{/if}
>{$userAdmin->pagingData[pages].label.start} - {$userAdmin->pagingData[pages].label.end}</a>
{/section}
<br><br>
<form method="POST" action="#" name="userStats">
<input type="hidden" name="process" value="1">
<input type="hidden" name="action" id="action" value="0">
<a href="javascript:void(0);" onclick="javascript:selectAll(true);">SELECT ALL</a>&nbsp;-&nbsp;<a href="javascript:void(0);" onclick="javascript:selectAll(false);">DESELECT ALL</a>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="The Special Button" onClick="javascript:setNegativeCB();" />
<table border="1" bordercolor="#dddddd" cellpadding="2">
<tr>
	<td> - </td>
	<td><b>ID</b></td>
	<td><b>Name</b></td>
	<td><b>E-mail</b></td>
	<td><b>Password</b></td>
	<td><b>Type</b></td>
	<td><b>Registered</b></td>
	<td><b>Activated</b></td>
	<td><b>Pips</b></td>
	<td><b>Status</b><br>
	<span style="color: green; font-weight: bold">subscr</span>/<span style="color: blue">trial</span></td>
</tr>

{section name=users loop=$userAdmin->UserDataArr}

{if $userAdmin->is2w && $userAdmin->UserDataArr[users].days>(-15) && $userAdmin->UserDataArr[users].days<15 && $userAdmin->UserDataArr[users].sDaysLeft>(-15) && $userAdmin->UserDataArr[users].sDaysLeft<15}

<tr>
	<td><input id="{$smarty.section.users.iteration}" type="checkbox" name="emailsArr[]" value="{$userAdmin->UserDataArr[users].email}"></td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].userid}
	<input type="hidden" id="subscr{$smarty.section.users.iteration}" value="{$userAdmin->UserDataArr[users].subscrflag}" />
	<input type="hidden" id="trial{$smarty.section.users.iteration}" value="{$userAdmin->UserDataArr[users].ontrial}" />
	<input type="hidden" id="pips{$smarty.section.users.iteration}" value="{$userAdmin->getUserPips($userAdmin->UserDataArr[users].acttmstmp)}" />
	</td>
	<td>{$userAdmin->UserDataArr[users].name}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].email}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].psswd}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].group}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].registered}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].activated}</td>

	{assign var="pips" value=$userAdmin->getUserPips($userAdmin->UserDataArr[users].acttmstmp,$userAdmin->UserDataArr[users].endtmstmp)}
	<td
	{if $pips<0}
	 style="color: #ff0000"
	{/if}
	>

	{if $userAdmin->UserDataArr[users].activated!=0}
		{$pips}
	{/if}

    {*
		{section name=notifications loop=$userAdmin->UserDataArr[users].notifications}
			<a style="cursor: pointer" target="_blank" onClick="window.open('_notify_sample.php?t={$userAdmin->UserDataArr[users].notifications[notifications]}','', 'width=400, height=250, left=50, top=50, scrollbars=yes, resizable=yes');">{$userAdmin->UserDataArr[users].notifications[notifications]}</a>&nbsp;
		{/section}
	*}
	</td>
	<!-- td nowrap="nowrap">{*$userAdmin->UserDataArr[users].subscribed*}</td -->
	<td nowrap="nowrap">
	{*if $userAdmin->UserDataArr[users].sDaysLeft*}
	<span style="color: green; font-weight: bold">{$userAdmin->UserDataArr[users].sDaysLeft} of {$userAdmin->UserDataArr[users].subscr_period} days  </span>
	 | {$userAdmin->UserDataArr[users].sDate}
	{*/if*}
	</td>
	<td nowrap="nowrap">
	<a class="fakelink" onclick="deleteUser({$userAdmin->UserDataArr[users].userid});"><img src="images/icon_no.gif" border="0" /></a>
	<a href="javascript:void(0);" onclick="showActCode({$userAdmin->UserDataArr[users].userid});">act. code</a>
	<input onClick="this.select();" style="display: none;" id="code{$userAdmin->UserDataArr[users].userid}" type="text" value="{$userAdmin->getActivationLink($userAdmin->UserDataArr[users].userid,$userAdmin->UserDataArr[users].email)}" name="code{$userAdmin->UserDataArr[users].userid}" />
	</td>
</tr>

{elseif !$userAdmin->is2w}
<tr>
	<td><input id="{$smarty.section.users.iteration}" type="checkbox" name="emailsArr[]" value="{$userAdmin->UserDataArr[users].email}"></td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].userid}
	<input type="hidden" id="subscr{$smarty.section.users.iteration}" value="{$userAdmin->UserDataArr[users].subscrflag}" />
	<input type="hidden" id="trial{$smarty.section.users.iteration}" value="{$userAdmin->UserDataArr[users].ontrial}" />
	<input type="hidden" id="pips{$smarty.section.users.iteration}" value="{$userAdmin->getUserPips($userAdmin->UserDataArr[users].acttmstmp)}" />
	</td>
	<td>{$userAdmin->UserDataArr[users].name}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].email}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].psswd}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].group}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].registered}</td>
	<td nowrap="nowrap">{$userAdmin->UserDataArr[users].activated}</td>

	{assign var="pips" value=$userAdmin->getUserPips($userAdmin->UserDataArr[users].acttmstmp,$userAdmin->UserDataArr[users].endtmstmp)}
	<td
	{if $pips<0}
	 style="color: #ff0000"
	{/if}
	>

	{if $userAdmin->UserDataArr[users].activated!=0}
		{$pips}
	{/if}

    {*
		{section name=notifications loop=$userAdmin->UserDataArr[users].notifications}
			<a style="cursor: pointer" target="_blank" onClick="window.open('_notify_sample.php?t={$userAdmin->UserDataArr[users].notifications[notifications]}','', 'width=400, height=250, left=50, top=50, scrollbars=yes, resizable=yes');">{$userAdmin->UserDataArr[users].notifications[notifications]}</a>&nbsp;
		{/section}
	*}
	</td>
	<!-- td nowrap="nowrap">{*$userAdmin->UserDataArr[users].subscribed*}</td -->
	<td nowrap="nowrap">
	{if $userAdmin->UserDataArr[users].subscrflag==1}
		{include file="_order_status.tpl" status_type="short"}
	{/if}
	{if $userAdmin->UserDataArr[users].sDaysLeft}
	<span style="color: green; font-weight: bold">{$userAdmin->UserDataArr[users].sDaysLeft}d left</span>
	 | {$userAdmin->UserDataArr[users].sDate}
	{elseif $userAdmin->UserDataArr[users].ontrial}
	<span style="color: blue">{$userAdmin->UserDataArr[users].ontrial}d left
	{else}
	--
	{/if}
	</td>
	<td nowrap="nowrap">
	<a class="fakelink" onclick="deleteUser({$userAdmin->UserDataArr[users].userid});"><img src="images/icon_no.gif" border="0" /></a>
	<a href="javascript:void(0);" onclick="showActCode({$userAdmin->UserDataArr[users].userid});">act. code</a>
	<input onClick="this.select();" style="display: none;" id="code{$userAdmin->UserDataArr[users].userid}" type="text" value="{$userAdmin->getActivationLink($userAdmin->UserDataArr[users].userid,$userAdmin->UserDataArr[users].email)}" name="code{$userAdmin->UserDataArr[users].userid}" />
	</td>
</tr>
{/if}
{/section}

</table>

<br><br>
{section name=pages loop=$userAdmin->pagingData}
| <a href="admin.php?p=userstats&start={$userAdmin->pagingData[pages].param.start}" {if $smarty.get.start==$userAdmin->pagingData[pages].param.start}style="text-decoration: none"{/if}
>{$userAdmin->pagingData[pages].label.start} - {$userAdmin->pagingData[pages].label.end}</a>
{/section}
<!--
<br>Select Notification Type&nbsp;&nbsp;<select id="mailshotMode" name="mailshotMode">
  	{section name=modes loop=$userAdmin->mailModes}
         <option value="{$userAdmin->mailModes[modes]}">{$userAdmin->mailModes[modes]}</option>
  	{/section}
</select>

&nbsp;&nbsp;<input type="button" value="Send Notifications" onClick="javascript:formSubmit();">
-->
</form>
